package main
import (
	"fmt"
	"sort"
)

//map的排序

func main(){
	map1 := make(map[int]int)
	fmt.Println("map1 : ",map1)
	map1[21] = 22
	map1[12] = 11
	map1[333] = 33
	map1[24] = 77
	fmt.Println("map1 : ",map1)

	//可以将map中的key取出来放到切片中，然后在排序切片，在重新按照key遍历map
	var keys []int
	for k,_ := range map1{
		keys = append(keys,k)
	}
	sort.Ints(keys)
	fmt.Println(keys)

	for _,k := range keys{
		fmt.Println("====",k,"====",map1[k])
	}
}